#include<stdio.h>

#define SIZE 10

int sum(int * start, int * end);

int main() {

    int nums[SIZE] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

    int result = sum(nums, nums + SIZE);
    printf("The total of nums id %d\n", result);

    return 0;
}


// usr pointer arithmetic
int sum(int * start, int * end) {
    int total = 0;
    while (start < end) {
        total += *start;
        start++;
    }    
    return total;
}